home *** CD-ROM | disk | FTP | other *** search
- /* JavaScript for Talk-n-Mail
- Copyright (c) 1999-2000, SoftApproach Corp. All rights reserved
- */
-
- var CONST_COOKIE_NULL = '_NULL'
- var ibReloaded = false
- var ibIsIE
- var iiPageWidth
-
- /* Show/Hide object */
- function fvShow(asObject, abShow)
- {
- var lsTmp
- var lObj
-
- if(ibIsIE)
- {
- if(abShow)
- lsTmp = "visible"
- else
- lsTmp = "hidden"
- // End if
- }
- else
- {
-
- if(abShow)
- lsTmp = "show"
- else
- lsTmp = "hide"
- // End if
- }
-
- lObj = fobjGetDivObjectByName(asObject)
- lObj.visibility = lsTmp
-
- }
-
- // Returns one of the frames or background
- // for attributes
- function fobjGetDivObject(aiIndex)
- {
- var lsName
-
- lsName = fsGetDivName(aiIndex)
- return fobjGetDivObjectByName(lsName)
- }
-
- function fsGetDivName(aiIndex)
- {
- if(iarAniDivData[iarAniDivData.iIndex].bHasBackground)
- return "div" + aiIndex
- else
- return "div" + aiIndex + "Frame0"
- // End if
- }
-
-
- /* Center one object */
- function fvCenterObject(asObject)
- {
- var lobjTmp
-
- if(ibIsIE)
- {
- lobjTmp = document.all[asObject].style
-
- // Use parseInt() to get rid of the px sufix
- lobjTmp.left = (fiPageWidth() -
- parseInt(lobjTmp.width)) / 2
- }
- else
- {
- lobjTmp = document.layers[asObject]
- // Width and Height are not available in Netscape Layer
- lobjTmp.left = (fiPageWidth() - lobjTmp.clip.width) / 2
- }
-
- }
-
- function fiPageWidth()
- {
- if(ibIsIE)
- return parseInt(document.body.offsetWidth)
- else
- return window.innerWidth
- // End if
- }
-
-
-
- function fvResize()
- {
-
- // Center Objects
- if(iiPageWidth != fiPageWidth())
- {
- // Reload
- if(!ibIsIE)
- {
- bReloaded = !bReloaded
- if(!bReloaded)
- document.location.href = document.location.href
- // End if
- }
-
- fvCenterObject("divPage")
- fvCenterObject("divButtons1")
- fvCenterObject("divButtons2")
-
- fvCenterObject("divSound")
- fvCenterObject("divTitleFrame1")
- fvCenterObject("divTitleFrame2")
-
- // Keep the new size
- iiPageWidth = fiPageWidth()
-
- }
- }
-
- // Call myself periodically to check the window resize
- // Netscape disables onResize event once embedded sound is added
- function fvTimer()
- {
- fvResize()
- setTimeout("fvTimer()", 1000)
- }
-
- function fiGetSubStringPos(asString, asSubString, abCaseSensitive)
- {
- // Return: 0 - n, -1 = not found
- var lsString
- var lsSubString
-
- lsString = new String(asString)
- lsSubString = new String(asSubString)
-
- if(!abCaseSensitive)
- {
- lsString.toLowerCase()
- lsSubString.toLowerCase()
- }
-
- return lsString.indexOf(lsSubString)
- }
-
- function fobjGetDivObjectByName(asName)
- {
- var lsNameRoot
- if(ibIsIE)
- {
- return document.all[asName].style
- }
- else
- {
- lObj = document.divPage.layers[asName]
- if(lObj) return lObj
-
- lObj = document.layers[asName]
- if(lObj) return lObj
-
- alert("Name not found: " + asName)
- }// End if
- }
-
- function fvInit()
- {
-
- ibIsIE = (document.layers) ? false : true
-
- // Center me for the first time Need to init the values
- iiPageWidth = 0
- fvResize()
-
- // Error handler
- window.onerror = fvWindowErrorHandler
-
- // Netscape?
- if(!ibIsIE)
- {
-
- fvTimer()
- }
-
- // Show all objects
- fvShow("divPage", true)
- fvShow("divButtons1", true)
- fvShow("divSound", true)
-
- // Page animation
- fvAniInit()
- }
-
- /* Get a value */
- function fsGetCookie(sName)
- {
- var iOffset
- var iEnd
- var sSearch = sName + "="
- var lsValue
-
- // if there are any cookies
- if (document.cookie.length > 0)
- {
- iOffset = document.cookie.indexOf(sSearch)
-
- // if cookie exists
- if (iOffset != -1) {
- iOffset += sSearch.length
-
- // set index of beginning of sValue
- iEnd = document.cookie.indexOf(";", iOffset)
-
- // set index of iEnd of cookie sValue
- if (iEnd == -1)
- iEnd = document.cookie.length
-
- lsValue = unescape(document.cookie.substring(iOffset, iEnd))
- if(lsValue == CONST_COOKIE_NULL){lsValue = ''}
- return lsValue
- }
- }
- }
-
- /* Sets cookie values. Expiration date is optional: To keep the cookie for
- later sessions */
- function fvSetCookie(sName, sValue, dtExpire)
- {
- sValue = escape(sValue)
- // undefined var will erase the entire entry in NC
- if(sValue == null || sValue == '' || sValue == 'undefined'){sValue =
- CONST_COOKIE_NULL}
- if(dtExpire != null)
- {
- sValue += "; expires="
-
- // IE
- if(document.all)
- {
- sValue += dtExpire.toGMTString()}
- // NC
- else
- {
- sValue += fsToCookieDate(dtExpire)
- }
- }
- document.cookie = sName + "=" + sValue
- }
-
- // For NC, otherwise toGMTString() is good enough
- // Officially: 'Sunday, 06-Jan-01 23:12:40 GMT'
- // Tested: '06-01-01 23:12:40 GMT'
- function fsToCookieDate(dtDate)
- {
- var lsDate = ''
-
- lsDate += fsNumber2String(dtDate.getDate()) + "-"
- lsDate += fsNumber2String(dtDate.getMonth() + 1) + "-"
- lsDate += fsNumber2String(dtDate.getYear() + 1) + " "
- lsDate += fsNumber2String(dtDate.getHours()) + ":"
- lsDate += fsNumber2String(dtDate.getMinutes()) + ":"
- lsDate += fsNumber2String(dtDate.getSeconds()) + " GMT"
-
- return lsDate
- }
- // Return a 2 byte string
- function fsNumber2String(alValue)
- {
- return alValue < 10 ? '0' + alValue : alValue
- }
-
- function LTrim(String)
- {
- var i = 0
- var j = String.length - 1
-
- if (!String) return ''
-
- for (i = 0; i < String.length; i++)
- {
- if (String.substr(i, 1) != ' ' &&
- String.substr(i, 1) != '\t')
- break;
- }
-
- if (i <= j)
- return (String.substr(i, (j+1)-i));
- else
- return '';
- }
-
- function RTrim(String)
- {
- var i = 0
- var j = String.length - 1
-
- if (!String) return ''
-
- for(j = String.length - 1; j >= 0; j--)
- {
- if (String.substr(j, 1) != ' ' &&
- String.substr(j, 1) != '\t')
- break;
- }
-
- if (i <= j)
- return (String.substr(i, (j+1)-i));
- else
- return '';
- }
-
- function Trim(String)
- {
- if (String == null)
- return '';
-
- return RTrim(LTrim(String));
- }
-
-
-